﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ueEngine.Biz.Inf.LogicEntity;
using ueEngine.Biz.Core.AppService.Recruitment;
using ueEngine.Biz.Core.AppService.Support;

namespace ueEngine.Web.WebLogic.PageDataProxy
{
    public class HomeJobDetail<T> : IDataProxy<HomeJobDetailModel>
    {
        /// <summary>
        /// 职位详情页面内容缓存，包含一个参数。recuritId
        /// </summary>
        /// <param name="keys"></param>
        /// <returns></returns>
        protected override string BuildKey(params string[] keys)
        {
            if (keys.Length == 0)
            {
                throw new Exception("职位详情页面缓存参数不足");
            }
            return CachePrefix + "HomJobDetail:" + keys[0];
        }

        protected override HomeJobDetailModel BuildRefrashAction(params string[] keys)
        {
            int id = 1;
            if (keys.Length == 0 || !Int32.TryParse(keys[0],out id))
            {
                throw new Exception("职位详情页面缓存参数不足");
            }
            return new HomeJobDetailModel() {
                Recruitment = new RecruitService(string.Empty).GetRecruitment(id),
                DiscussTimeForRecruitment = new SystemService().QueryOfDiscussTimeForRecruitment(id)
            };
        }

        protected override bool CheckedParams(params string[] keys)
        {
            int i = 0;
            return keys.Length >= 1 && Int32.TryParse(keys[0], out i);
        }
    }
    public class HomeJobDetailModel
    {
        public RecruitSheetModel Recruitment { get; set; }
        public int DiscussTimeForRecruitment { get; set; }
    }
}
